<template>
    <div class="addform">
        <h3>添加非药品收费项目</h3>
        <el-form :model="fmeditem" :rules="rules" ref="fmeditem" label-width="100px" class="demo-ruleForm">
            <el-form-item label="项目编码" prop="ItemCode">
                <el-input v-model="fmeditem.ItemCode"></el-input>
            </el-form-item>
            <el-form-item label="项目名称" prop="ItemName">
                <el-input v-model="fmeditem.ItemName"></el-input>
            </el-form-item>
            <el-form-item label="规格" prop="Format">
                <el-input v-model="fmeditem.Format"></el-input>
            </el-form-item>
            <el-form-item label="单价" prop="Price">
                <el-input v-model="fmeditem.Price"></el-input>
            </el-form-item>
            <el-form-item label="所属费用ID" prop="ExpClassID">
                <el-input v-model="fmeditem.ExpClassID" type="number" style="width: 100px;"></el-input>
            </el-form-item>
            <el-form-item label="执行科室ID" prop="DeptID">
                <el-input v-model="fmeditem.DeptID" type="number" style="width: 100px;"></el-input>
            </el-form-item>
            <el-form-item label="拼音助记码" prop="MnemonicCode">
                <el-input v-model="fmeditem.MnemonicCode"></el-input>
            </el-form-item>
            <el-form-item label="项目类型" prop="RecordType">
                <el-select v-model="fmeditem.RecordType" placeholder="请选择项目类型">
                    <el-option label="检查" :value=Number(1)></el-option>
                    <el-option label="检验" :value=Number(2)></el-option>
                    <el-option label="处置" :value=Number(3)></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="getaddFmeditem">添加</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import fmeditem from '@/api/his/fmeditem'
export default {
    data() {
        return {
            fmeditem: {
                ItemCode: '',
                ItemName: '',
                Format: '',
                Price: '',
                ExpClassID: 1,
                DeptID: 1,
                MnemonicCode: '',
                RecordType: ''
            },
            rules: {
                ItemCode: [
                    { required: true, message: '请输入项目编码', trigger: 'blur' },
                    { min: 9, max: 9, message: '长度在 9个字符', trigger: 'blur' }
                ],
                ItemName: [
                    { required: true, message: '请输入项目名称', trigger: 'blur' },
                    { min: 1, max: 20, message: '长度在 1到20个字符', trigger: 'blur' }
                ],
                Format: [
                    { required: true, message: '请输入规格', trigger: 'blur' },
                    { min: 1, max: 5, message: '长度在 1到5个字符', trigger: 'blur' }
                ],
                Price: [
                    { required: true, message: '请输入单价', trigger: 'blur' },
                    { min: 3, max: 10, message: '长度在 3到10个字符', trigger: 'blur' }
                ],
                ExpClassID: [
                    { required: true, message: '请输入所属费用ID', trigger: 'blur' },
                  
                ],
                DeptID: [
                    { required: true, message: '请输入执行科室ID', trigger: 'blur' },
                  
                ],
                MnemonicCode: [
                    { required: true, message: '请输入所属拼音助记码', trigger: 'blur' },
                    { min: 3, max: 10, message: '长度在 3到10个字符', trigger: 'blur' }
                ],
            },
            state:false
        }
    },
    methods: {
        async getaddFmeditem(){
            this.$refs.fmeditem.validate(async valid => {
                if (!valid) return    
                const res=await fmeditem.getaddFmeditemAPI(this.fmeditem)
                if(res.data.success){
                    this.$message.success('添加成功');
                    this.$router.push("/fmeditem")
                }else{
                    this.$message.error('添加失败');
                }  
            })

        }
    },
}
</script>

<style scoped>
</style>